package co.gov.medellin.ssti.sub.paoyer.common.exception;

import java.sql.SQLException;

public class OracleKnownException {

	public OracleKnownException() {
	}

	public static void traslateSQLException(SQLException se)
			throws UserException, SystemException {

		switch (se.getErrorCode()) {
		case 1:
			throw new UserException(new CommonUserException().getModuleVO(),
					CommonUserException.DUPLICATE_PRIMARY_KEY);
		case 1401:
			throw new UserException(new CommonUserException().getModuleVO(),
					CommonUserException.VALUE_TOO_LARGE);
		case 2292:
			throw new UserException(new CommonUserException().getModuleVO(),
					CommonUserException.ANOTHER_RECORD_ASOCIATED);

		case 20101:
			throw new UserException(new CommonUserException().getModuleVO(),
					CommonUserException.INVALID_VALUE_FOR_MAIN_OPTION);

		default:
			throw new SystemException(
					new CommonSystemException().getModuleVO(),
					CommonSystemException.QUERY_EXCEPTION, se, se.getMessage());
		}

	}

}